home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-05-30 | 3.2 KB | 116 lines | [TEXT/MMCC] |
- // ostream standard header
- #ifndef _OSTREAM_
- #define _OSTREAM_
- #include <streambuf>
-
- #if __MWERKS__
- #pragma options align=mac68k
- #endif
-
- // class ostream
- class ostream : virtual public ios {
- public:
- ostream(streambuf *_S)
- { init(_S); }
- ostream(_Uninitialized)
- : ios(_Noinit) {}
- virtual ~ostream();
- _Bool opfx();
- void osfx();
- ostream& operator<<(ostream& (*_F)(ostream&))
- {return ((*_F)(*this)); }
- ostream& operator<<(ios& (*_F)(ios&))
- {(*_F)(*(ios *)this); return (*this); }
- ostream& operator<<(const char *);
- ostream& operator<<(char _C)
- {put(_C); return (*this); }
- ostream& operator<<(unsigned char _C)
- {return (*this << (char)_C); }
- ostream& operator<<(short _X)
- {return (_Print(&"B hoB hxB hd"[_If()], _X)); }
- ostream& operator<<(unsigned short _X)
- {return (_Print(&"B hoB hxB hu"[_If()], _X)); }
- ostream& operator<<(int _X)
- {return (_Print(&"B oB xB d"[_If()], _X)); }
- ostream& operator<<(unsigned int _X)
- {return (_Print(&"B oB xB u"[_If()], _X)); }
- ostream& operator<<(long _X)
- {return (_Print(&"B loB lxB ld"[_If()], _X)); }
- ostream& operator<<(unsigned long _X)
- {return (_Print(&"B loB lxB lu"[_If()], _X)); }
- ostream& operator<<(float _X)
- {return (_Print(&"P. eP. fP. g"[_Ff()], _Pr(), _X)); }
- ostream& operator<<(double _X)
- {return (_Print(&"P.leP.lfP.lg"[_Ff()], _Pr(), _X)); }
- ostream& operator<<(long double _X)
- {return (_Print(&"P.LeP.LfP.Lg"[_Ff()], _Pr(), _X)); }
- ostream& operator<<(void *);
- ostream& operator<<(streambuf&);
- ostream& put(char);
- ostream& write(const char *, int);
- ostream& write(const unsigned char *_S, int _N)
- {return (write((const char *)_S, _N)); }
- ostream& flush();
- streampos tellp()
- {
- streampos pos = rdbuf()->pubseekoff(0, ios::cur, ios::out);
- if (pos == streampos(EOF))
- setstate(ios::badbit);
- return pos;
- }
- ostream& seekp(streampos pos)
- {
- pos = rdbuf()->pubseekpos(pos, ios::out);
- if (pos == streampos(EOF))
- setstate(ios::badbit);
- return *this;
- }
-
- ostream& seekp(streamoff off, ios::seek_dir dir)
- {
- streampos pos = rdbuf()->pubseekoff(off,dir,ios::out);
- if (pos == streampos(EOF))
- setstate(ios::badbit);
- return *this;
- }
- #if _HAS_SIGNED_CHAR
- ostream& operator<<(signed char _C)
- {return (*this << (char)_C); }
- ostream& write(const signed char *_S, int _N)
- {return (write((const char *)_S, _N)); }
- #endif /* _HAS_SIGNED_CHAR */
- protected:
- int _Ff()
- {return ((flags() & floatfield) == scientific ? 0
- : (flags() & floatfield) == fixed ? 4 : 8); }
- int _If()
- {return ((flags() & basefield) == oct ? 0
- : (flags() & basefield) == hex ? 4 : 8); }
- void _Pad(const char *, char *, int);
- int _Pr();
- ostream& _Print(const char *, ...);
- };
- // manipulators
- ostream& endl(ostream&);
- ostream& ends(ostream&);
- ostream& flush(ostream&);
-
- #if __MWERKS__
- #pragma options align=reset
- #endif
-
- #endif
-
- /*
- * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
- * Consult your license regarding permissions and restrictions.
- */
-
- /* Change log:
- * 1994-06-04: PlumHall baseline
- * 1994-09-30: Applied diffs for Fri Aug 26 00:51:20 1994
- * 1994-10-07: Inserted MW changes.
- * 1994-10-14: XL04 change istream(streambuf *_S) to init derived
- *//* Change log:
- */
-